package edu.zut.controller;

import com.sun.xml.internal.bind.v2.model.core.ID;
import edu.zut.service.EmpService;
import edu.zut.service.impl.EmpServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeleteEmpServlet", value = "/emp/delete")
public class DeleteEmpServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String emp_id = request.getParameter("emp_id");
        int id = Integer.parseInt(emp_id);
        //调用业务层操作
        EmpService empService = new EmpServiceImpl();
        //删除后是否需要返回值，根据自己的需求定义
        empService.deleteEmpById(id);
        //删除后依然停留在home.jsp
        response.sendRedirect(request.getContextPath() + "/emp/showAll");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
